Crate salsa20[−][src]
Expand description
The Salsa20 stream cipher.
Cipher functionality is accessed using traits from re-exported
cipher
crate.
Security Warning
This crate does not ensure ciphertexts are authentic! Thus ciphertext integrity is not verified, which can lead to serious vulnerabilities!
USE AT YOUR OWN RISK!
Diagram
This diagram illustrates the Salsa quarter round function. Each round consists of four quarter-rounds:
Legend:
- ⊞ add
- ‹‹‹ rotate
- ⊕ xor
Usage
use salsa20::{Salsa20, Key, Nonce}; use salsa20::cipher::{NewCipher, StreamCipher, StreamCipherSeek}; let mut data = [1, 2, 3, 4, 5, 6, 7]; let key = Key::from_slice(b"an example very very secret key."); let nonce = Nonce::from_slice(b"a nonce."); // create cipher instance let mut cipher = Salsa20::new(&key, &nonce); // apply keystream (encrypt) cipher.apply_keystream(&mut data); assert_eq!(data, [182, 14, 133, 113, 210, 25, 165]); // seek to the keystream beginning and apply it again to the `data` (decrypt) cipher.seek(0); cipher.apply_keystream(&mut data); assert_eq!(data, [1, 2, 3, 4, 5, 6, 7]);
Re-exports
pub use cipher;
Structs
The Salsa20 family of stream ciphers (implemented generically over a number of rounds).
xsalsa20
XSalsa20 is a Salsa20 variant with an extended 192-bit (24-byte) nonce.
Constants
Functions
hsalsa20
The HSalsa20 function defined in the paper “Extending the Salsa20 nonce”
Type Definitions
Key type.
Nonce type.
Salsa20/8 stream cipher (reduced-round variant of Salsa20 with 8 rounds, not recommended)
Salsa20/12 stream cipher (reduced-round variant of Salsa20 with 12 rounds, not recommended)
Salsa20/20 stream cipher (20 rounds; recommended)
xsalsa20
EXtended Salsa20 nonce (192-bit/24-byte)